!----------------------------------------------------------------!
!    Basic module and ATS module   by Zhang Xuke     2021.9.6    !
!----------------------------------------------------------------!
        MODULE BASIC_MOD
        !----------time related
        INTEGER::              NLOOP
        REAL*8,PARAMETER::     CFL=0.5D0
        REAL*8::               DT,TIME,TEND,TSYS
        !----------scheme related
        INTEGER,PARAMETER::                       MUSCL=1
        INTEGER,PARAMETER::                       LIMIT=1
        INTEGER,PARAMETER::                       AXIAL=0
        INTEGER,PARAMETER::                       MAT=0  !  0:Jacobian matrix 1:full matrix
        !-----------mesh information
        
        INTEGER,PARAMETER::                        D0=2               ! additional cells in one direction
        INTEGER::                                  NI                 ! mesh point in x direction
        INTEGER::                                  NJ                 ! mesh point in y direction
        INTEGER::                                  XCELLS             ! number of cell in x direction
        INTEGER::                                  YCELLS             ! number of cell in y direction
        REAL*8::                                   DX,DY,DT_GLOBAL
        REAL*8,POINTER::                           X(:,:)             ! x-coordinate of each mesh point 
        REAL*8,POINTER::                           Y(:,:)             ! y-coordinate of each mesh point 
        REAL*8,POINTER::                           XC(:,:)            ! x-coordinate of center point in cell 
        REAL*8,POINTER::                           YC(:,:)            ! y-coordinate of center point in cell 
        REAL*8,POINTER::                           VOL(:,:)           ! volume of each cell
        REAL*8,POINTER::                           AREA_S(:,:,:)      ! information about south(down) interface in cell
        REAL*8,POINTER::                           AREA_E(:,:,:)      ! information about east(right) interface in cell
        REAL*8,POINTER::                           AREA_N(:,:,:)      ! information about north(up) interface in cell
        REAL*8,POINTER::                           AREA_W(:,:,:)      ! information about west(left) interface in cell
        !------------grid property
        REAL*8,PARAMETER::                         R00=8.31434D0
        REAL*8,POINTER::                           PP(:,:)            ! pressure
        REAL*8,POINTER::                           TT(:,:)            ! temperature
        REAL*8,POINTER::                           TT0(:,:)            ! temperature
        REAL*8,POINTER::                           DD(:,:)            ! density 
        REAL*8,POINTER::                           UU(:,:)            ! velocity in x direction
        REAL*8,POINTER::                           VV(:,:)            ! velocity in y direction
        REAL*8,POINTER::                           CC(:,:)            ! sound speed
        REAL*8,POINTER::                           MA(:,:)            ! mach number
        REAL*8,POINTER::                           CP(:,:)            ! specific heat at constan pressure
        REAL*8,POINTER::                           HH(:,:)            ! enthalpy
        REAL*8,POINTER::                           EE(:,:)            ! internal engergy
        REAL*8,POINTER::                           GA(:,:)            ! specific heat
        REAL*8,POINTER::                           WAV(:,:)           ! average molecular weight
        REAL*8,POINTER::                           RGAS(:,:)          ! constant number of air gas
        REAL*8,POINTER::                           CS(:,:,:)          ! conserved variables
        REAL*8,POINTER::                           CS0(:,:,:)          ! conserved variables
        REAL*8,POINTER::                           FLUXE(:,:,:)       ! east flux of cell
        REAL*8,POINTER::                           FLUXW(:,:,:)       ! west flux of cell
        REAL*8,POINTER::                           FLUXN(:,:,:)       ! north flux of cell
        REAL*8,POINTER::                           FLUXS(:,:,:)       ! south flux of cell
        REAL*8,POINTER::                           RHS(:,:,:)         ! residual
        REAL*8,POINTER::                           CMS(:,:,:)         ! source term
        REAL*8,POINTER::                           MD(:,:,:,:)        ! Jacobian matrix
        !----chemical related variables
        INTEGER::                                  NS                 ! number of species
        INTEGER::                                  NR                 ! number of reaction equation
        INTEGER::                                  NT                 ! number of third body
        INTEGER::                                  NFAL               ! number of fall off reaction
        INTEGER::                                  O2,H2,N2,AR,CH3OH,C2H4,CH4,OH   ! oxygen,hydrogen,nitrogen
        REAL*8,POINTER::                           DI(:,:,:)          ! component density
        REAL*8,POINTER::                           MI(:,:,:)          ! component mole fraction
        REAL*8,POINTER::                           MO(:,:,:)          ! component mole 
        REAL*8,POINTER::                           MC(:,:,:)          ! component mole density
        REAL*8,POINTER::                           YI(:,:,:)          ! component mass fraction
        REAL*8,POINTER::                           HI(:)              ! component enthalpy
        REAL*8,POINTER::                           SI(:)              ! component entropy
        REAL*8,POINTER::                           EI(:)              ! component internal energy
        REAL*8,POINTER::                           CPI(:)             ! component specific heat
        REAL*8,POINTER::                           RI(:)              ! component gas constant
        REAL*8,POINTER::                           AW(:)              ! component molecular weight
        REAL*8,POINTER::                           AF(:)              ! pre-exponent factor
        REAL*8,POINTER::                           BF(:)              ! temperature index
        REAL*8,POINTER::                           EF(:)              ! activation energy
        REAL*8,POINTER::                           KF(:)              ! raction rate of forward equation
        REAL*8,POINTER::                           KB(:)              ! raction rate of backward equation
        REAL*8,POINTER::                           KP(:)              ! reaction constant 
        REAL*8,POINTER::                           THIRD(:)           ! three body coefficient
        REAL*8,POINTER::                           STOIF(:,:)         ! stoichiometric coefficient for reactant
        REAL*8,POINTER::                           STOIB(:,:)         ! stoichiometric coefficient for product
        REAL*8,POINTER::                           COEF0(:,:)         ! polynomial coeffients used to compute cpi/hi/si when T>1000
        REAL*8,POINTER::                           COEF1(:,:)         ! polynomial coeffients used to compute cpi/hi/si when T<1000
        REAL*8,POINTER::                           TB(:,:)            ! polynomial coeffients used to compute cpi/hi/si when T<1000  
        INTEGER,ALLOCATABLE,DIMENSION(:)::         RNUMFAL,TYPEFAL,FLAGFAL
        REAL*8,ALLOCATABLE,DIMENSION(:)::          AFFAL,BFFAL,EFFAL
        REAL*8,ALLOCATABLE,DIMENSION(:,:)::        TOREFAL            
        CHARACTER*8,POINTER::                      SPEC(:)
        END MODULE BASIC_MOD